﻿using DeviceAlarmService.MessagePush.Communication;
using DeviceAlarmService.MessagePush.Play;
using DeviceAlarmService.SystemService;

namespace DeviceAlarmService
{
    public class RunService : DeviceManagement.DeviceConnection.DMS
    {
        public RunService()
        {
            //拉起服务
            StartService();
        }

        public void StartService()
        {
            //获取全局配置
            ConfigService.GetSettings();
            //开启推送服务服务
            if (ConfigService.Configuration.enablePushService)
            {
                PushService.StartService();
                PushService.LogEvent += OperationLog;
            }
            if (ConfigService.Configuration.enableVoiceBroadcastingService)
            {
                //播放服务
                PlayService.StartService();
            }
        }

        public void Start(string id)
        {
            if (File.Exists($"json/{id}.json"))
            {
                string config = File.ReadAllText($"json/{id}.json");
                //开启服务
                Open(config);
            }
        }

        public void Stop(string id)
        {
            Close(id);
        }

        public void S7Config()
        {
            DeviceManagement.DeviceConnection.SiemensPlc.ConfigurationGeneration configuration = new();
        }
    }
}
